package EDesign23;

import java.util.ArrayList;
import java.util.List;

public class ASimpFactory {



    // 工厂 ， 接口工厂，抽象工厂
    //

    public static void main(String[] args) {

        System.out.println("今天整理了房间，真的好棒啊 ~ ");
    }

  // 1 ******************************************************
    public class RecommendMusicService {
        public List<String> recommend(String style) {
            List<String> recommendMusicList = new ArrayList<>();

            if ("metal".equals(style)) {
                recommendMusicList.add("Don't cry");
            } else if ("country".equals(style)) {
                recommendMusicList.add("Hotel california");
            } else if ("grunge".equals(style)) {
                recommendMusicList.add("About a girl");
            }else {
                recommendMusicList.add("My heart will go on");
            }

            return recommendMusicList;
        }
    }

    // 1 ******************************************************
    public class RecommendMusicService2 {
        public List<String> recommend(String style) {
            List<String> recommendMusicList = new ArrayList<>();

            if ("metal".equals(style)) {
                recommendMetal(recommendMusicList);
            } else if ("country".equals(style)) {
                recommendCountry(recommendMusicList);
            } else if ("grunge".equals(style)) {
                recommendGrunge(recommendMusicList);
            }else {
                recommendPop(recommendMusicList);
            }

            return recommendMusicList;
        }

        private void recommendPop(List<String> recommendMusicList) {
            recommendMusicList.add("My heart will go on");
            recommendMusicList.add("Beat it");
        }

        private void recommendGrunge(List<String> recommendMusicList) {
            recommendMusicList.add("About a girl");
            recommendMusicList.add("Smells like teen spirit");
        }

        private void recommendCountry(List<String> recommendMusicList) {
            recommendMusicList.add("Hotel california");
            recommendMusicList.add("Take Me Home Country Roads");
        }

        private void recommendMetal(List<String> recommendMusicList) {
            recommendMusicList.add("Don't cry");
            recommendMusicList.add("Fade to black");
        }
    }


    // 2.0 ******************************************************
    // 类单一职责
    public class MetalMusicRecommendService {
        public List<String> recommend(){
            List<String> recommendMusicList = new ArrayList<>();

            recommendMusicList.add("Don't cry");
            recommendMusicList.add("Fade to black");

            return recommendMusicList;
        }
    }

    public class GrungeMusicRecommendService {
        public List<String> recommend(){
            List<String> recommendMusicList = new ArrayList<>();

            recommendMusicList.add("Don't cry");
            recommendMusicList.add("Fade to black");

            return recommendMusicList;
        }
    }
    public class CountryMusicRecommendService {
        public List<String> recommend(){
            List<String> recommendMusicList = new ArrayList<>();

            recommendMusicList.add("Don't cry");
            recommendMusicList.add("Fade to black");

            return recommendMusicList;
        }
    }public class PopMusicRecommendService {
        public List<String> recommend(){
            List<String> recommendMusicList = new ArrayList<>();

            recommendMusicList.add("Don't cry");
            recommendMusicList.add("Fade to black");

            return recommendMusicList;
        }
    }

    public class RecommendMusicService3 {

        private MetalMusicRecommendService metalMusicRecommendService = new MetalMusicRecommendService();
        private GrungeMusicRecommendService grungeMusicRecommendService = new GrungeMusicRecommendService();
        private CountryMusicRecommendService countryMusicRecommendService = new CountryMusicRecommendService();
        private PopMusicRecommendService popMusicRecommendService = new PopMusicRecommendService();

        public List<String> recommend(String style) {
            List<String> recommendMusicList = new ArrayList<>();

            if ("metal".equals(style)) {
                metalMusicRecommendService.recommend();
            } else if ("country".equals(style)) {
                countryMusicRecommendService.recommend();
            } else if ("grunge".equals(style)) {
                grungeMusicRecommendService.recommend();
            }else {
                popMusicRecommendService.recommend();
            }

            return recommendMusicList;
        }

    }

    // 3.0 ******************************************************
    public interface MusicRecommendInterface {
        List<String> recommend();
    }

    public class GrungeMusicRecommendService4 implements MusicRecommendInterface {
        public List<String> recommend() {
            List<String> recommendMusicList = new ArrayList<>();

            recommendMusicList.add("About a girl");
            recommendMusicList.add("Smells like teen spirit");

            return recommendMusicList;
        }
    }
    public class MetalMusicRecommendService4 implements MusicRecommendInterface {
        public List<String> recommend() {
            List<String> recommendMusicList = new ArrayList<>();

            recommendMusicList.add("About a girl");
            recommendMusicList.add("Smells like teen spirit");

            return recommendMusicList;
        }
    }
    public class CountryMusicRecommendService4 implements MusicRecommendInterface {
        public List<String> recommend() {
            List<String> recommendMusicList = new ArrayList<>();

            recommendMusicList.add("About a girl");
            recommendMusicList.add("Smells like teen spirit");

            return recommendMusicList;
        }
    }
    public class PopMusicRecommendService4 implements MusicRecommendInterface {
        public List<String> recommend() {
            List<String> recommendMusicList = new ArrayList<>();

            recommendMusicList.add("About a girl");
            recommendMusicList.add("Smells like teen spirit");

            return recommendMusicList;
        }
    }

    public class MusicRecommendServiceFactory {
        MusicRecommendInterface createMusicRecommend(String style) {
            if ("metal".equals(style)) {
                return new MetalMusicRecommendService4();
            } else if ("country".equals(style)) {
                return new CountryMusicRecommendService4();
            } else if ("grunge".equals(style)) {
                return new GrungeMusicRecommendService4();
            } else {
                return new PopMusicRecommendService4();
            }
        }
    }

    public class RecommendMusicService4 {

        private MusicRecommendServiceFactory recommendMusicServiceFactory = new MusicRecommendServiceFactory();

        public List<String> recommend(String style) {

            MusicRecommendInterface musicRecommend = recommendMusicServiceFactory.createMusicRecommend(style);

            return musicRecommend.recommend();
        }
    }



}
